#!/bin/bash

if [ $# -ne 1 ] ; then
	echo "USAGE : dockerstoprm container_name"
	exit 1
fi

CONTAINER_NAME=$1

CONTAINER_ID=`docker ps | grep -w "${CONTAINER_NAME}" | awk '{print $1}'`

echo "docker stop ${CONTAINER_NAME}"

docker stop "${CONTAINER_NAME}"
if [ $? -ne 0 ] ; then
	exit 1
fi

echo "docker rm ${CONTAINER_ID}"

docker rm ${CONTAINER_ID}
if [ $? -ne 0 ] ; then
	exit 1
fi

exit 0

